package mutilthread;

/**
 * Created with IntelliJ IDEA.
 * Description: 创建一个线程，计算 1 + 2 + 3 + ... + 1000
 * User: Li_yizYa
 * Date: 2025—04—08
 * Time: 17:25
 */
public class Demo24 {
    private static int result;

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            int sum = 0;
            for (int i = 0; i < 1000; i++) {
                sum += i;
            }
            result = sum;
        });
        t.start();
        t.join();
        System.out.println("result = " + result);
    }
}
